#include <iostream>
#include <vector>
using namespace std;

bool GS[2005][2005];
int S[2005];


int getf(int x) {
	if (S[x] == x) return x;
	return S[x] = getf(S[x]);
}

void merge(int a, int b) {
	int u = getf(a), v = getf(b);
	if (u != v) {
		S[u] = v;
		S[a] = v;
	}
}

int main() {
	char c;
	int x, y;
	int n, m;
	cin >> n >> m;

	for (int i = 1; i <= 2 * n + 1; ++i) {
		S[i] = i;
	}

	for (int i = 1; i <= m; ++i) {
		cin >> c >> x >> y;
		if (c == 'E') {
			merge(x + n, y);
			merge(y + n, x);
		} else {
			merge(x, y)
			merge(x + n, y + n);
		}
	}

	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (S[i] == i) ++ans;
	}

	cout << ans << endl;
	return 0;
}
